package com.ruoyi.web.controller.smartHighway;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.smartHighway.domain.NoticeRelease;
import com.ruoyi.smartHighway.service.INoticeReleaseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 消息通知Controller
 * 
 * @author ljj
 * @date 2024-08-06
 */
@RestController
@RequestMapping("/smartHighway/noticeRelease")
public class NoticeReleaseController extends BaseController {

    @Autowired
    private INoticeReleaseService noticeReleaseService;

    /**
     * 查询消息通知列表
     */
    @PreAuthorize("@ss.hasPermi('smartHighway:noticeRelease:list')")
    @GetMapping("/list")
    public TableDataInfo list(NoticeRelease noticeRelease) {
        startPage();
        List<NoticeRelease> list = noticeReleaseService.selectNoticeReleaseList(noticeRelease);
        return getDataTable(list);
    }

    /**
     * 导出消息通知列表
     */
    @PreAuthorize("@ss.hasPermi('smartHighway:noticeRelease:export')")
    @Log(title = "消息通知", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NoticeRelease noticeRelease) {
        List<NoticeRelease> list = noticeReleaseService.selectNoticeReleaseList(noticeRelease);
        ExcelUtil<NoticeRelease> util = new ExcelUtil<NoticeRelease>(NoticeRelease.class);
        util.exportExcel(response, list, "消息通知数据");
    }

    /**
     * 获取消息通知详细信息
     */
    @PreAuthorize("@ss.hasPermi('smartHighway:noticeRelease:query')")
    @GetMapping(value = "/{noticeId}")
    public AjaxResult getInfo(@PathVariable("noticeId") Long noticeId) {
        return success(noticeReleaseService.selectNoticeReleaseByNoticeId(noticeId));
    }

    /**
     * 新增消息通知
     */
    @PreAuthorize("@ss.hasPermi('smartHighway:noticeRelease:add')")
    @Log(title = "消息通知", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NoticeRelease noticeRelease) {
        return toAjax(noticeReleaseService.insertNoticeRelease(noticeRelease));
    }

    /**
     * 修改消息通知
     */
    @PreAuthorize("@ss.hasPermi('smartHighway:noticeRelease:edit')")
    @Log(title = "消息通知", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NoticeRelease noticeRelease) {
        return toAjax(noticeReleaseService.updateNoticeRelease(noticeRelease));
    }

    /**
     * 删除消息通知
     */
    @PreAuthorize("@ss.hasPermi('smartHighway:noticeRelease:remove')")
    @Log(title = "消息通知", businessType = BusinessType.DELETE)
	@DeleteMapping("/{noticeIds}")
    public AjaxResult remove(@PathVariable Long[] noticeIds) {
        return toAjax(noticeReleaseService.deleteNoticeReleaseByNoticeIds(noticeIds));
    }
}
